package cn.gxufe.reliable.message.consumer;

import cn.gxufe.reliable.message.api.config.RMSApiConfigForConsumer;
import cn.gxufe.reliable.message.consumer.kafka.KafkaRMSConsumer;
import cn.gxufe.reliable.message.consumer.service.HandleMessageServiceImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;

import java.util.HashMap;

/**
 * @author yingjie.rong
 **/
@SpringBootApplication
@Import(RMSApiConfigForConsumer.class)
@EnableFeignClients
@EnableEurekaClient
@EnableDiscoveryClient
public class ConsumerApplication {

    @Bean
    public KafkaRMSConsumer kafkaRMSConsumer(){
        return new KafkaRMSConsumer();
    }


    @Bean
    public DefaultKafkaConsumerFactory defaultKafkaConsumerFactory(){
        HashMap<String,Object> hashMap = new HashMap(3);
        hashMap.put("bootstrap.servers","192.168.18.4:9092");
        hashMap.put("key.deserializer","org.apache.kafka.common.serialization.IntegerDeserializer");
        hashMap.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
        return new DefaultKafkaConsumerFactory(hashMap);
    }

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class,args);
    }
}
